Constructs an ordered enumeration from an unordered enumeration
Syntax
Example
Library/Library.Test/TestOrderedEnumeration.cs
C# | Copy Code |
---|
var order = new OrderedEnumeration<byte>(new byte[1]);
System.Collections.IEnumerator e = ((System.Collections.IEnumerable)order).GetEnumerator();
Assert.IsTrue(e.MoveNext());
Assert.IsFalse(e.MoveNext());
try
{
object val = e.Current;
GC.KeepAlive(val);
Assert.Fail();
}
catch (InvalidOperationException) { }
try
{
e.Reset();
Assert.Fail();
}
catch (NotSupportedException) { } |
VB.NET | Copy Code |
---|
Dim order As var = New OrderedEnumeration(Of Byte)(New Byte(1) {})
Dim e As System.Collections.IEnumerator = (DirectCast(order, System.Collections.IEnumerable)).GetEnumerator()
Assert.IsTrue(e.MoveNext())
Assert.IsFalse(e.MoveNext())
Try
Dim val As Object = e.Current
GC.KeepAlive(val)
Assert.Fail()
Catch generatedExceptionName As InvalidOperationException
End Try
Try
e.Reset()
Assert.Fail()
Catch generatedExceptionName As NotSupportedException
End Try |
Requirements
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
See Also